package ro.peoplecentric.ctc.common;


import java.text.MessageFormat;
import java.util.ResourceBundle;

/**
 * Used to load resource messages from internationalised resource files.
 * 
 * @author Vitalie Svet
 * @since 17/08/2013
 */
public class CtcCommonResources {

	/**
	 * Resources keys.
	 */
	public static final String START_UNIT_TEST_KEY = "logger.info.start.unit.test";
	public static final String FAILED_UNIT_TEST_RUN_KEY = "logger.sever.failed.unit.test";
	public static final String START_LOAD_DATA_KEY = "logger.info.load.data";
	public static final String START_LOAD_DATA_DONE_KEY = "logger.info.load.data.done";
	public static final String START_UNLOAD_DATA_KEY = "logger.info.unload.data";
	public static final String START_UNLOAD_DATA_DONE_KEY = "logger.info.unload.data.done";
	
	/**
	 * CatergoryDaoTest message keys
	 */
	public static final String CATEGORYDAO_TEST_GET_ORDERED_RESULT = "categorydao.test.testThatDaoGetsAllCategoriesOrderedAscByName";
	public static final String CATEGORYDAO_TEST_GET_ALL_RESULT = "categorydao.test.testThatDaoGetsAllEntities";
	public static final String CATEGORYDAO_TEST_GET_PAGINATED_RESULT = "categorydao.test.testGetPaginatedResult";
	
	/**
	 * RegionDaoTest message keys
	 */
	public static final String REGIONDAO_TEST_GET_ORDERED_RESULT = "regiondao.test.testThatDaoGetsAllRegionsOrderedAscByName";
	public static final String REGIONDAO_TEST_GET_ALL_RESULT = "regiondao.test.testThatDaoGetsAllEntities";
	public static final String REGIONDAO_TEST_GET_PAGINATED_RESULT = "regiondao.test.testGetPaginatedResult";
	
	/**
	 * ItemDaoTest message keys
	 */
	public static final String ITEMDAO_TEST_GET_ORDERED_RESULT = "itemdao.test.testThatDaoGetsAllItemssOrderedAscByName";
	public static final String ITEMDAO_TEST_GET_ALL_RESULT = "itemdao.test.testThatDaoGetsAllEntities";
	public static final String ITEMDAO_TEST_GET_PAGINATED_RESULT = "itemdao.test.testGetPaginatedResult";
	public static final String ITEMDAO_TEST_GET_LAST_MODIFIED = "itemdao.test.testGettingLastFiveModifiedItems";
	public static final String ITEMDAO_TEST_GET_SEARCH_ITEMS = "itemdao.test.testFindingItemsBySearchCriteria";
	
	/**
	 * Regions service message keys
	 */
	public static final String REGIONSERVICE_TEST_GET_ALL_RESULT = "regionservice.test.testThatServiceGetsAllEntities";
	
	/**
	 * Categories service message keys
	 */
	public static final String CATEGORYSERVICE_TEST_GET_ALL_RESULT = "categoryservice.test.testThatServiceGetsAllEntities";
	
	/**
	 * Item service message keys
	 */
	public static final String ITEMSERVICE_TEST_GET_ALL_RESULT = "itemservice.test.testThatServiceGetsAllEntities";
	public static final String ITEMSERVICE_TEST_GET_ORDERED_RESULT = "itemservice.test.testThatDaoGetsAllItemsOrderedAscTitle";
	
	private static ResourceBundle resourceBundle;

	private CtcCommonResources() {
	}

	/**
	 * Loads all resources that are managed by this class.
	 */
	static {
		resourceBundle = ResourceBundle.getBundle(CtcCommonResources.class
				.getName());
	}

	/**
	 * Gets resources message by key, populating it with parameters.
	 * 
	 * @param keyName
	 * @param parameters
	 * @return
	 */
	public static String getMessage(String keyName, Object... parameters) {
		return MessageFormat.format(resourceBundle.getString(keyName),
				parameters);
	}
}
